<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<!--
*************************************************************************
* The contents of this file are subject to the Openbravo  Public  License
* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
* Version 1.1  with a permitted attribution clause; you may not  use this
* file except in compliance with the License. You  may  obtain  a copy of
* the License at http://www.openbravo.com/legal/license.html
* Software distributed under the License  is  distributed  on  an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific  language  governing  rights  and  limitations
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
* All portions are Copyright (C) 2010-2015 Openbravo SLU
* All Rights Reserved.
* Contributor(s):  ______________________________________.
************************************************************************
-->
<html>
<head>
<meta http-equiv="Expires" content="Tue, 24 Apr 1979 00:00:01 GMT">
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
<link rel="stylesheet" href="./qunit/qunit.css" type="text/css" media="screen">


<script type="text/javascript" src="../js/LAB.min.js"></script>
<script type="text/javascript"  src="./qunit/qunit.js"></script>
<script src="../js/BigDecimal-all-1.0.1.min.js"></script>

<title>Openbravo - Test Suite</title>
</head>
<body>
  <script>
    var isomorphicDir='../../org.openbravo.userinterface.smartclient/isomorphic/',
        OBTest = { testStarted: false,
              completed: false,
              executed: {}
            };
    $LAB.setGlobalDefaults({CacheBust:true});
    
    QUnit.done(function (details) {
        if (OBTest.testStarted){
          isc.Class.fireOnPause('testExecution', function(){
            if (QUnit.config.queue.length === 0) {
              // mark execution as completed so Selenium gets notified
              OBTest.completed = true;
              OBTest.failed = details.failed;
              OBTest.passed = details.passed;
              OBTest.total = details.total;
              OBTest.runtime = details.runtime;
              console.log('Tests completed',OBTest);
            }
          }, 1000);
        }
    });
    
    QUnit.log(function (details) {
      var result = OBTest.executed, testCase, assertName, i;
      
      if (!result[details.module + ' - ' + details.name]){
          result[details.module + ' - ' + details.name] = {};
      }
      
      testCase = result[details.module + ' - ' + details.name];
      
      assertName = details.message;
      testCase[assertName] = { success: details.result, runtime: details.runtime};
      
      if (!details.result) {
          testCase[assertName].expected = details.expected;
          testCase[assertName].actual = details.actual;
          testCase[assertName].source = details.source;
      }
    });

    function OBStartApplication() {
      OBTest.testStarted = true;
      $LAB.script('../../../org.openbravo.client.kernel/OBCLKER_Kernel/TestResources');
    }
  </script>
  
  <script type="text/javascript" src="../../org.openbravo.userinterface.smartclient/isomorphic/ISC_Combined.js"></script>
  <script type="text/javascript" src="../../org.openbravo.userinterface.smartclient/isomorphic/ISC_History.js"></script>
  
  <script>
  (
    function () {
      var requestApplication = function () {
          // Now we have a valid session, all StaticResources can be retrieved
          isc.RPCManager.sendRequest({actionURL:'../../../org.openbravo.client.kernel/OBCLKER_Kernel/StaticResources?_mode=3.00&_skinVersion=Default', 
              evalResult: false,
              callback:function (resp, data) {
                  test('Static Resources can be requested', function () {
                      var app = data, idx;
                      idx = app.indexOf("src='");
                      QUnit.ok(idx !== -1, 'Static Resources file is present');
                      app = app.substring(idx + 5);
                      
                      idx = app.indexOf(".js'>");
                      QUnit.ok(idx !== -1, 'StaticResource file is a js file');
                      app = app.substring(0, idx + 3);
                      
                      if (idx !== -1) {
                        $LAB.script(app);
                      }
                  });
              }});
      };
        
      // at this point we have SC, we need a sesison to get the application
      isc.RPCManager.sendRequest({actionURL:'../../../secureApp/LoginHandler.html?user=Openbravo&password=openbravo', 
            evalResult: true,
            callback:function (resp, data) {
            	QUnit.module('org.openbravo.security');
            	QUnit.test('Login', function (){
                QUnit.ok(data && data.showMessage === false, 'Login correct');
                requestApplication();
              });
            }});
    }
  )();
  </script>
  
  <h1 id="qunit-header">Openbravo - Test Suite</h1>
  <h2 id="qunit-banner"></h2>
  <div id="qunit-testrunner-toolbar"></div>
  <h2 id="qunit-userAgent"></h2>
  <ol id="qunit-tests"></ol>
</body>
</html>